// pages/check/list/list.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		http:getApp().globalData.map,
		zz:'',
		dp:'',
		name:''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		console.log(options)
		wx.getStorage({
			key:'uid',
			success:(e)=>{
				this.setData({
					uid:e.data.uid,
					list:options
				})
			}
		})
		 this.kq()
	},
	kq(){
		wx.getLocation({
		     type: 'wgs84',
		     success: (res)=> {
		       var latitude = res.latitude
		       var longitude = res.longitude
		       var speed = res.speed
		       var accuracy = res.accuracy
		       this.setData({ latitude: latitude, longitude: longitude})
		     }
		   })
	},
	onGuideTap: function(event) {
		this.kq()
		wx.chooseLocation({
			success:(e)=>{
				console.log(e)
				let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
				    let x = e.longitude;
				    let y = e.latitude;
				    let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
				    let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
				    let lngs = z * Math.cos(theta) + 0.0065;
				    let lats = z * Math.sin(theta) + 0.006;
				this.setData({
					map:e.name,
					lat:lats,
					lng:lngs
				})
			}
		})
	},
	sc(en){
		let that=this
		wx.chooseImage({
			count: 1,
			sizeType:'compressed',
			success: (e) => {
				wx.uploadFile({
					url: getApp().globalData.http3,
					filePath:e.tempFilePaths[0],
					name:'picturePath',
					success: function(res) {
						let a=JSON.parse(res.data)
						console.log(a.data.headImage)
						if(en.currentTarget.dataset.id==1){
							that.setData({
								dp:a.data.headImage
							})
						}else{
							that.setData({
								zz:a.data.headImage
							})
						}
					}
				});
			},fail: () => {
				this.kq()
			}
		})
	},
	name(e){
		this.setData({
			name:e.detail.value
		})
	},
	sure(){
		let a=this.data.list
		console.log(a)
		if(this.data.name!=''&&this.data.dp!=''&&this.data.zz!=''&&this.data.map!=''){
			let header=''
			if(this.data.list.zhuangtai==1){
				header=getApp().globalData.http+'action=ManufactorApply'
			}else{
				header=getApp().globalData.http+'action=shopApp'
			}
			console.log(a.serverType)
			wx.request({
				url:header+'&uid='+this.data.uid+'&mobile='+a.mobile+'&shopName='
				+a.shopName+'&shopType='+a.shopType+'&shopAddress='+a.shopAddress+'&shopInfo='+a.shopInfo
				+'&prov='+a.prov+'&city='+a.city+'&county='+a.county+'&serverType='+a.serverType+'&realName='+this.data.name+
				'&shopImg='+this.data.dp+'&yyzz='+this.data.zz+
				'&Longitude='+this.data.lng+'&Latitude='+this.data.lat,
				success:(e)=>{
					console.log(a)
					this.setData({
						state:true
					})
				}
			})
		}else{
			wx.showToast({
				icon:'none',
				title:'请正确上传信息'
			})
		}
	},
	none(e){
		if(e.currentTarget.dataset.id==1){
			this.setData({
				dp:""
			})
		}else{
			this.setData({
				zz:""
			})
		}
	}
})
